<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>短信模版</title>
    <link rel="stylesheet" href="/Public/css/magic-check.css">
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Public/css/gxxjkefu-normalize.css">
    <link rel="stylesheet" href="/Public/css/model.css">
    <link rel="stylesheet" href="/Public/css/pager.css">
    <link rel="stylesheet" href="/Public/css/feedback.css">
    <link rel="stylesheet" href="/Public/css/magic-check.css">

    <style>
        .notice_info {
            padding: 25px 4% 3%;
            line-height: 35px;
            color: #979797;
            float: left;
            width: 100%;
            background: #ffffff;
        }
        .note_box li{
            width: 100%;
            margin: 0 auto;
            padding: 10px 0;
            border-bottom:  dashed 1px #cccccc;
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: center;
        }
        .note_box textarea{
            margin-left: 20px;
            line-height: 25px;
        }
        .opt{height:30px;line-height:24px}
    </style>
</head>
<body>
<div class="scrollbar" id="style-1" style="overflow:scroll;overflow-x:hidden;margin: 0;width: 100%">
<div id="main_C" style="float: left;width: 99%">
    <div class="title_info">
        <span>短信</span>
    </div>
    <div class="white_bgColor notice_info">
        <ul class="note_box" id="msg_li">

        </ul>
        <div style="clear: both;margin: 20px 0 0">
            <button style="float: right;width: 100px" class="btn btn-info" id="search_submit" type="submit" onclick="send()">发送</button>
        </div>
        <!--分页-->
        <div style="text-align: center;margin: 100px auto 0">
            <ul class="pagination" id="page2"></ul>
            <div class="pageJump">
                <span>跳转到</span>
                <input type="text"/>
                <span>页</span>
                <button type="button" class="button"></button>
            </div>
        </div>
    </div>
</div>
</div>

<script src="/Public/js/pager.js"></script>
<script src="/Public/js/jquery-3.2.1.js"></script>
<script src="/Public/js/layer/layer.js"></script>
<script src="/Public/js/layui/layui.js"></script>
<script>

    get_msg(1);
    function get_msg(n) {
        $.post("<{$SERVER_NAME}>/User/get_msg",{page:n},function (data) {
             if(data.code='1001'){
                 var obj=data.result;
                 var tol=data.tol;
                 var count=data.count;
                 /*分页*/
                 if(n==1){
                     Page({
                         num:tol,					//页码数
                         startnum:1,				//指定页码
                         elem:$('#page2'),		//指定的元素
                         callback:function(n){	//回调函数
                             get_msg(n);
                         }
                     });
                     if(count<=10){
                         $("#page2").hide();
                     }else{
                         $("#page2").show();
                     }
                 }
                var len=obj.length;
                 var s="";
                 for (var i=0;i<len;i++){
                     var j=i+1;
                     s+="<li> <div class='opt'> <input class='magic-radio' type='radio' id='"+obj[i].id+"' name='radio' value='"+obj[i].id+"' /> " +
                        "<label for='"+obj[i].id+"'>短信"+j+"</label> </div>" +
                        "<textarea disabled='disabled'  cols='130' rows='6'>"+obj[i].content+"</textarea> </li>";
                 }
                 document.getElementById("msg_li").innerHTML = s;
             }else {

             }
        });
    }
    function send() {
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var value=$('input[name="radio"]:checked').val();
        var phone=window.parent.get_phone();
        if(phone=="" || phone==null){
            layer.close(index);
            layer.alert("请选择用户！", {title: '提示框', icon: 3});
            return false;

        }

        layer.alert("确认发送短信给用户？", {title: '提示框', icon: 3}, function (index) {
            $.post("<{$SERVER_NAME}>/User/message_send",{phone:phone,id:value},function (data) {
                console.log('00000002222',data);
               if(data.code='1001'){
                   layer.alert("发送成功！", {title: '提示框', icon: 1});
               }else {
                   layer.alert("发送失败！", {title: '提示框', icon: 1});
               }
            });

        });
        layer.close(index);
        console.log('3333333333',value);
        console.log('phonephone',phone);
    }
</script>
</body>
</html>